<?php

require_once(sfConfig::get('sf_lib_dir').'/filter/base/BaseFormFilterPropel.class.php');

/**
 * Occupant filter form base class.
 *
 * @package    utility
 * @subpackage filter
 * @author     Your name here
 */
class BaseOccupantFormFilter extends BaseFormFilterPropel
{
  public function setup()
  {
    $this->setWidgets(array(
      'station_id'      => new sfWidgetFormPropelChoice(array('model' => 'Station', 'add_empty' => true)),
      'building_id'     => new sfWidgetFormPropelChoice(array('model' => 'Building', 'add_empty' => true)),
      'consumer_no'     => new sfWidgetFormFilterInput(),
      'army_no'         => new sfWidgetFormFilterInput(),
      'rank'            => new sfWidgetFormFilterInput(),
      'name'            => new sfWidgetFormFilterInput(),
      'unit'            => new sfWidgetFormFilterInput(),
      'date_occupied'   => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => true)),
      'date_vacated'    => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => true)),
      'occupied_status' => new sfWidgetFormFilterInput(),
      'occupant_state'  => new sfWidgetFormFilterInput(),
      'status'          => new sfWidgetFormFilterInput(),
      'created_at'      => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => true)),
      'updated_at'      => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => true)),
    ));

    $this->setValidators(array(
      'station_id'      => new sfValidatorPropelChoice(array('required' => false, 'model' => 'Station', 'column' => 'id')),
      'building_id'     => new sfValidatorPropelChoice(array('required' => false, 'model' => 'Building', 'column' => 'id')),
      'consumer_no'     => new sfValidatorPass(array('required' => false)),
      'army_no'         => new sfValidatorPass(array('required' => false)),
      'rank'            => new sfValidatorPass(array('required' => false)),
      'name'            => new sfValidatorPass(array('required' => false)),
      'unit'            => new sfValidatorPass(array('required' => false)),
      'date_occupied'   => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false)))),
      'date_vacated'    => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false)))),
      'occupied_status' => new sfValidatorPass(array('required' => false)),
      'occupant_state'  => new sfValidatorPass(array('required' => false)),
      'status'          => new sfValidatorPass(array('required' => false)),
      'created_at'      => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false)))),
      'updated_at'      => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false)))),
    ));

    $this->widgetSchema->setNameFormat('occupant_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    parent::setup();
  }

  public function getModelName()
  {
    return 'Occupant';
  }

  public function getFields()
  {
    return array(
      'id'              => 'Number',
      'station_id'      => 'ForeignKey',
      'building_id'     => 'ForeignKey',
      'consumer_no'     => 'Text',
      'army_no'         => 'Text',
      'rank'            => 'Text',
      'name'            => 'Text',
      'unit'            => 'Text',
      'date_occupied'   => 'Date',
      'date_vacated'    => 'Date',
      'occupied_status' => 'Text',
      'occupant_state'  => 'Text',
      'status'          => 'Text',
      'created_at'      => 'Date',
      'updated_at'      => 'Date',
    );
  }
}
